Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nexssp/ensure

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nexssp/ensure

Install easy on multiple os, check also @nexssp/os for different functions..

  • 1.1.28
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-71.43%
Maintainers
1
Weekly downloads
 
Created
Source

@nexssp/ensure

NEW: 02.04.2022 Added workflows + support for MacOS.

# or on js ensureInstalled('git')
nexssp-ensure git # will install git on any os you are. If it is installed it will return the path.

It's more then @nexssp/os function as it has translator. What it means? that for example on Gentoo to install git you need to put emerge dev-vcs/git (not git). We cover that in the @nexssp/extend. We will be building the database of what and which distro what kind of changes has. For example:

Translator file example

Git

Below is just: All Gentoos use 'dev-vcs/git'.

const os = require('@nexssp/os/legacy')
// first tag means all versions. We specified 1, because it does matter for the first tag
const GentooFirst = os.getTags(os.distros.GENTOO, 1).first()
module.exports = {
  [GentooFirst]: 'dev-vcs/git', // All gentoos will have this other systems has git
}
const result = ensureInstalled("git") => it will automatically install git on your machine
  • Function just make sure your program is installed (Linux, WSL, Windows) and macOS soon..

  • This package is used in many packages. For example in the @nexssp/languages where you can install over 50 programming languages. Try npx @nexssp/languages r install or npx @nexssp/languages php install.

API

Functions

  • ensureInstalled(command/package, installCommand, options)
  • which(command) - returns path of the command/program, false if does not exist.

Examples

const { ensureInstalled } = require('@nexssp/ensure')

const path = ensureInstalled('jq', 'apt install jq', {
  progress: cliArgs.progress,
})

// You can also pass 2 parameters and install command will be generated based on @nexssp/os and translators.
const path2 = ensureInstalled('lua', {
  progress: cliArgs.progress,
})

// Windows Subsystem for Linux
const path3 = ensureInstalled('wsl jq', 'wsl -u root apt install jq')

CLI tool

nexssp-ensure jq --install="apt install jq"

# Windows Subsystem for Linux
nexssp-ensure "wsl jq" --install="wsl -u root apt install jq"

Development

Translator files

Example 1

When ensure installing the packages it is looking at the translator files. Here are the examples:

const os = require('@nexssp/os/legacy')

// first tag means all versions. We specified 1, because it does matter for the first tag which is Windows
const Windows = os.getTags(os.distros.WINDOWS, 1).first() // first is always Windows. You could use also "win32", "linux", "darwin" .. all from https://nodejs.org/api/process.html#process_process_platform, but also distros based on @nexssp/os tags

module.exports = {
  [Windows]: {
    install: `powershell -command "Set-ExecutionPolicy RemoteSigned -scope CurrentUser" ; powershell -command "iex (new-object net.webclient).downloadstring('https://get.scoop.sh')"`,
  },
}

Example 2

const os = require('@nexssp/os/legacy')

const GentooFirst = os.getTags(os.distros.GENTOO, 1).first()

module.exports = {
  [GentooFirst]: 'dev-vcs/git', // All gentoos will have this other systems has git, other systems will have standard.
}

Keywords

FAQs

Package last updated on 29 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc